package com.zx.zxpicture.application.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.zx.zxpicture.infrstructure.api.aliyunai.model.CreateOutPaintingTaskResponse;
import com.zx.zxpicture.infrstructure.common.BaseResponse;
import com.zx.zxpicture.interfaces.dto.picture.*;
import com.zx.zxpicture.domain.picture.entity.Picture;
import com.zx.zxpicture.domain.user.entity.User;
import com.zx.zxpicture.interfaces.vo.PictureVO;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
* @author ZX
* @description 针对表【picture(图片)】的数据库操作Service
* @createDate 2025-02-19 15:03:21
*/
public interface PictureApplicationService extends IService<Picture> {
    /**
     * 图片上传
     * @param inputSource 图片数据源
     * @param pictureUploadRequest
     * @param loginUser
     * @return
     */
    PictureVO uploadPicture(Object inputSource, PictureUploadRequest pictureUploadRequest, User loginUser);

    /**
     * 获取查询条件
     *
     * @param pictureQueryRequest
     * @return
     */
    QueryWrapper<Picture> getQueryWrapper(PictureQueryRequest pictureQueryRequest);

    /**
     * 封装返回图片对象
     * @param picture
     * @param request
     * @return
     */
    public PictureVO getPictureVO(Picture picture, HttpServletRequest request);


    /**
     * 分页查询图片
     * @param picturePage
     * @param request
     * @return
     */
    public Page<PictureVO> getPictureVOPage(Page<Picture> picturePage, HttpServletRequest request);


    /**
     * 审批图片
     * @param pictureReviewRequest 审批图片请求
     * @param loginUser 审批用户
     */
    public void doPictureReview(PictureReviewRequest pictureReviewRequest,User loginUser);

    /**
     * 填充图片审核参数
     * @param picture
     * @param loginUser
     */
    public void fillReviewParams(Picture picture,User loginUser);

    /**
     * 通过多级缓存分页查询图片
     * @param pictureQueryRequest 分页查询请求
     * @param request 网页请求
     * @return
     */
    public Page<PictureVO> listPictureVOByPageWithCache(PictureQueryRequest pictureQueryRequest, HttpServletRequest request);
    /**
     * 批量抓取和创建图片
     * @param pictureUploadByBatchRequest 分页抓取请求
     * @param loginUser 抓取用户
     * @return 成功创建的图片数
     */
    Integer uploadPictureByBatch(
            PictureUploadByBatchRequest pictureUploadByBatchRequest,
            User loginUser
    );

    /**
     * 用户编辑图片
     * @param pictureEditRequest
     * @param loginUser
     */
    public void editPicture(PictureEditRequest pictureEditRequest, User loginUser);

    /**
     * 删除图片
     * @param pictureId
     * @param loginUser
     */
    public void deletePicture(long pictureId, User loginUser);

    /**
     * 删除压缩图和缩略图
     * @param oldPicture 压缩图
     */
    public void clearPictureFile(Picture oldPicture);


    /**
     * 根据颜色查询主色调相近的图片
     * @param spaceId 空间id
     * @param picColor 目标主色调
     * @param loginUser 用户
     * @return 图片列表（颜色越相近排名越靠前）
     */
    public List<PictureVO> searchPictureVOByColor(Long spaceId, String picColor, User loginUser);

    /**
     * 批量编辑图片
     * @param pictureEditByBatchRequest 编辑图片请求
     * @param loginUser
     */
    public void editPictureByBatch(PictureEditByBatchRequest pictureEditByBatchRequest, User loginUser);

    /**
     * 创建扩图任务
     * @param request 创建扩图任务请求参数
     * @return 创建扩图任务响应结果
     */
    public CreateOutPaintingTaskResponse createOutPaintingTask(CreatePictureOutPaintingTaskRequest request, User loginUser);

    void validPicture(Picture picture);

    public BaseResponse<PictureTagCategory> listPictureTagCategory();
}
